package com.only4play.practice.pay.payment.core.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.only4play.codegen.processor.api.*;
import com.only4play.codegen.processor.creator.GenCreator;
import com.only4play.codegen.processor.creator.IgnoreCreator;
import com.only4play.codegen.processor.dto.GenDto;
import com.only4play.codegen.processor.query.GenQuery;
import com.only4play.codegen.processor.updater.GenUpdater;
import com.only4play.codegen.processor.updater.IgnoreUpdater;
import com.only4play.codegen.processor.vo.GenVo;
import com.only4play.codegen.support.annotation.FieldDesc;
import com.only4play.codegen.support.constants.ValidStatus;
import com.only4play.codegen.support.model.BaseEntity;
import com.only4play.practice.common.enums.OrderState;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;

/**
 * 交易流水订单
 * @author mengdy
 */
@GenCreator(pkgName = "com.only4play.practice.pay.payment.model.creator")
@GenUpdater(pkgName = "com.only4play.practice.pay.payment.model.updater")
// findById方法
@GenVo(pkgName = "com.only4play.practice.pay.payment.model.vo")
// findByPage方法
@GenQuery(pkgName = "com.only4play.practice.pay.payment.model.query")
@GenCreateRequest(pkgName = "com.only4play.practice.pay.payment.model.request")
@GenUpdateRequest(pkgName = "com.only4play.practice.pay.payment.model.request")
@GenQueryRequest(pkgName = "com.only4play.practice.pay.payment.model.request")
@GenResponse(pkgName = "com.only4play.practice.pay.payment.model.response")
@GenDto(pkgName = "com.only4play.practice.pay.payment.model.dto")

@GenFeign(pkgName = "com.only4play.practice.pay.payment.model.feign")

// // 生成serviceImpl
// @GenObjectMapper(pkgName = "com.only4play.practice.pay.payment.entitymapper")
// // 生成serviceImpl
// @GenMapper(pkgName = "com.only4play.practice.pay.payment.core.mapper")
// @GenService(pkgName = "com.only4play.practice.pay.payment.core.service")
// @GenServiceImpl(pkgName = "com.only4play.practice.pay.payment.core.service.impl")
//
// @GenController(pkgName = "com.only4play.practice.pay.payment.core.controller")

@EqualsAndHashCode(callSuper = true)
@Data
@TableName(value = "pay_trade_payment_order")
public class TradePaymentOrder extends BaseEntity {

    @FieldDesc(name = "支付渠道接入点编号")
    private String channelPointCode;

    @FieldDesc(name = "支付流水状态")
    private OrderState status;

    @FieldDesc(name = "支付金额")
    private Long payAmount;

    @FieldDesc(name = "支付标题")
    private String title;

    @FieldDesc(name = "支付描述")
    private String descBody;

    /*   对应云停车 订单服务 orderNo */
    @FieldDesc(name = "商户业务订单号")
    private String mchTradeOrderNo;

    /*   对应云停车 订单服务 paymentId */
    @FieldDesc(name = "商户支付渠道订单号")
    private String mchTradChanOrderNo;

    /*  第三方支付渠道系统中的交易凭证 */
    @FieldDesc(name = "渠道支付交易凭证号")
    private String chanTraPayOrderNo;

    @FieldDesc(name = "业务服务名称")
    private String serviceName;

    @FieldDesc(name = "业务附加数据")
    private String attach;

    @FieldDesc(name = "特殊渠道扩展数据")
    private String specialExt;

    @FieldDesc(name = "客户端IP")
    private String clientIp;

    @FieldDesc(name = "openId")
    private String openId;

    @FieldDesc(name = "accountNo")
    private String accountNo;

    @FieldDesc(name = "支付时间")
    private Date payTime;

    @FieldDesc(name = "渠道回调时间")
    private Date channelCallbackTime;

    @FieldDesc(name = "回调业务时间")
    private Date callbackBusinessTime;

    @FieldDesc(name = "支付渠道返回码")
    private String chanErrCode;

    @FieldDesc(name = "支付渠道返回信息")
    private String chanRrrMsg;

    /** 是否启用状态 */
    @IgnoreUpdater
    @IgnoreCreator
    private ValidStatus validStatus;

    public void init() {
        setValidStatus(ValidStatus.VALID);
    }

    public void valid(){
        setValidStatus(ValidStatus.VALID);
    }

    public void invalid(){
        setValidStatus(ValidStatus.INVALID);
    }
}
